<%@ page language="java" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.utils.StringUtils"%>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.Date" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html:html >
<HEAD>
<TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
    <style type="text/css" media="print">
    @page
    {
        size: landscape;
        margin: 2cm;
    }
    </style>
</HEAD>
<logic:present name="wipFlush" scope="session">
<BODY TOPMARGIN=0>
<TABLE BORDER="0" align="center" width="100%">
    <TR>
        <TD WIDTH="90%" VALIGN="CENTER" ALIGN="CENTER" CLASS="NArialW">Wip Flush - <%=request.getParameter("heading")%> Report By Vendor <%=request.getParameter ( "holdHeading" )%></TD>
        <TD WIDTH="5%" VALIGN="CENTER" >
            <A HREF="javascript:window.print();" TITLE='Click to Print wip flush'><IMG HEIGHT="60" WIDTH="60" SRC="<%=chipTracContext%>/jsp/includes/images/printer_icon_small.gif" BORDER="0"></A>
        </TD>
    </TR>
    <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
    <TR BGCOLOR="#DEE1E2" ALIGN = "CENTER" padding="0">
        <TD WIDTH="9%" NOWRAP style="border-width:1px;" CLASS="tdThinBorderLTB"><FONT CLASS='NArialL'><FONT COLOR="#000000">Vendor Name</FONT></FONT></TD>
        <TD WIDTH="9%" NOWRAP style="border-width:1px;" CLASS="tdThinBorderLTB"><FONT CLASS='NArialL'><FONT COLOR="#000000">Part Number</FONT></FONT></TD>
        <%
            int month1TotalQty  = 0;
            int month2TotalQty  = 0;
            int month3TotalQty  = 0;
            int month4TotalQty  = 0;
            int month5TotalQty  = 0;
            int month6TotalQty  = 0;
            int month7TotalQty  = 0;
            int month8TotalQty  = 0;
            int month9TotalQty  = 0;
            int month10TotalQty = 0;
            int month11TotalQty = 0;
            int month12TotalQty = 0;
            Calendar calDate = new GregorianCalendar();
            calDate.setTime(new Date());
            for (int k = 0; k < 12; k++)
            {
        %>
                <TD WIDTH="9%" style="border-width:1px;" CLASS='<%=(k==11)?"tdThinBorderLRTB":"tdThinBorderLTB" %>'><FONT CLASS='NArialL'><FONT COLOR="#000000"><%= StringUtils.formatDateToString(calDate.getTime(),"MMM yyyy")%></FONT></FONT></TD>
        <%
                calDate.add( Calendar.MONTH, 1 );
            }
        %>
    </TR>
    <logic:iterate name="wipFlush" id="vendor" scope="session" type="com.scalar.chiptrack.operations.reports.WipFlushByMonth">
        <%
            month1TotalQty  += vendor.getMonth1Qty();
            month2TotalQty  += vendor.getMonth2Qty();
            month3TotalQty  += vendor.getMonth3Qty();
            month4TotalQty  += vendor.getMonth4Qty();
            month5TotalQty  += vendor.getMonth5Qty();
            month6TotalQty  += vendor.getMonth6Qty();
            month7TotalQty  += vendor.getMonth7Qty();
            month8TotalQty  += vendor.getMonth8Qty();
            month9TotalQty  += vendor.getMonth9Qty();
            month10TotalQty += vendor.getMonth10Qty();
            month11TotalQty += vendor.getMonth11Qty();
            month12TotalQty += vendor.getMonth12Qty();
        %>
        <TR BGCOLOR="#F2DBDB" ALIGN = "RIGHT">
            <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="vendor"/></FONT></TD>
            <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'>&nbsp;</FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth1Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth2Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth3Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth4Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth5Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth6Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth7Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth8Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth9Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth10Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth11Qty"/></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLBR"><FONT CLASS='NArialL'><bean:write name="vendor" property="formattedMonth12Qty"/></FONT></TD>
        </TR>
        <logic:iterate name="vendor" property="childMap" id="baseProductMap">
             <bean:define name="baseProductMap" property="value" id="baseProduct" type="com.scalar.chiptrack.operations.reports.WipFlushByMonth"/>
            <TR BGCOLOR="#CDCEE9" ALIGN = "RIGHT">
                <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'>&nbsp;</FONT></TD>
                <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="partNumber"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth1Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth2Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth3Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth4Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth5Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth6Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth7Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth8Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth9Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth10Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth11Qty"/></FONT></TD>
                <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLBR"><FONT CLASS='NArialL'><bean:write name="baseProduct" property="formattedMonth12Qty"/></FONT></TD>
            </TR>
            <logic:iterate name="baseProduct" property="childMap" id="productMap">
                 <bean:define name="productMap" property="value" id="product" type="com.scalar.chiptrack.operations.reports.WipFlushByMonth"/>
                <TR BGCOLOR="#CDCEE9" ALIGN = "RIGHT">
                    <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'>&nbsp;</FONT></TD>
                    <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="partNumber"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth1Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth2Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth3Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth4Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth5Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth6Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth7Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth8Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth9Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth10Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth11Qty"/></FONT></TD>
                    <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLBR"><FONT CLASS='NArialS'><bean:write name="product" property="formattedMonth12Qty"/></FONT></TD>
                </TR>
            </logic:iterate>
        </logic:iterate>
    </logic:iterate>
        <TR BGCOLOR="#DEE1E2" ALIGN="RIGHT">
            <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK">Grand Total</FONT></TD>
            <TD WIDTH="9%" NOWRAP ALIGN="LEFT" style="border-width:1px;" CLASS="tdThinBorderLB">&nbsp;</TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month1TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month2TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month3TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month4TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month5TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month6TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month7TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month8TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month9TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month10TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLB"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month11TotalQty)%></FONT></TD>
            <TD WIDTH="9%" style="border-width:1px;" CLASS="tdThinBorderLBR"><FONT CLASS='NArialL' STYLE="COLOR:BLACK"><%=StringUtils.getUSNumberFormat(month12TotalQty)%></FONT></TD>
        </TR>
    </TABLE>
</TABLE>
</BODY>
</logic:present>
<logic:notPresent  name="wipFlush" scope="session">
<BODY bgcolor='ffffff' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0' >
    <TABLE cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
        <TR>
            <TD>
                <TABLE align="center" border="0" width="40%" bgcolor="#FDF5E6">
                    <TR><TD>&nbsp;</TD></TR>
                    <TR><TD align="center" ><font class="NArialL" ><font color="red"><b>Session has been time out , Please close this window and login again.</b></font></font></TD></TR>
                    <TR><TD>&nbsp;</TD></TR>
                    <TR><TD align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></TD></TR>
                </TABLE>
            </TD>
       </TR>
       <TR><TD>&nbsp;</TD></TR>
    </TABLE>
</BODY>
</logic:notPresent>

</html:html>
